<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="js/vue.js"></script>
    <style>
        .box {
            border: 1px solid black;
            padding: 20px;
            margin-bottom: 20px;
        }
    </style>
</head>

<body>
    <div id="app" class="box">
        <h3>组件A</h3>
        <comp-b></comp-b>
        <comp-c></comp-c>
    </div>
    <template id="tempB">
        <div class="box">
            <h3>组件B</h3>
            <comp-d></comp-d>
            <comp-e></comp-e>
        </div>
    </template>
    <template id="tempC">
        <div class="box">
            <h3>组件C</h3>
        </div>
    </template>
    <template id="tempD">
        <div class="box">
            <h3>组件D</h3>
        </div>
    </template>
    <template id="tempE">
        <div class="box">
            <h3>组件E</h3>
        </div>
    </template>
</body>
<script>
    new Vue({
        el: '#app',
        beforeMount() {
            console.log("=>组件A-beforeMount")
        },
        mounted() {
            console.log("=>组件A-mounted")
        },
        components: {
            CompB: {
                template: "#tempB",
                beforeMount() {
                    console.log("==>组件B-beforeMount")
                },
                mounted() {
                    console.log("==>组件B-mounted")
                },
                components: {
                    CompD: {
                        template: "#tempD",
                        beforeMount() {
                            console.log("===>组件D-beforeMount")
                        },
                        mounted() {
                            console.log("===>组件D-mounted")
                        },
                    },
                    CompE: {
                        template: "#tempE",
                        beforeMount() {
                            console.log("===>组件E-beforeMount")
                        },
                        mounted() {
                            console.log("===>组件E-mounted")
                        },
                    }
                }
            },
            CompC: {
                template: "#tempC",
                beforeMount() {
                    console.log("==>组件C-beforeMount")
                },
                mounted() {
                    console.log("==>组件C-mounted")
                },
            }
        }
    });
</script>

</html>